/**
 * Created by xiongcheng on 2018/3/1.
 */

import Vue from 'vue'
import $ from 'jquery'
import _ from 'lodash'
import Bus from './bus'
import * as axios from 'axios'
import {sync} from 'vuex-router-sync'


/**
 * app初始化，注入一些插件，vue原型属性和方法
 */
export function appInitInject(store,router){
  // 同步route实例到vuex
  sync(store,router)
  // 注入原型工具类方法
  Vue.prototype.$axios = axios
  Vue.prototype.$_ = _
  Vue.prototype.$$ = $
  Vue.prototype.$bus = Bus


  //配置全局axios默认值
  // axios.defaults.baseURL = '/api'
  axios.defaults.timeout = 3000
  axios.defaults.headers.post['Content-Type'] = 'application/json'
  //此处是增加的代码，设置请求头的类型
  axios.defaults.headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8';
}

